package locations.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import locations.dao.DAOFactory;
import locations.dao.InstitutionDAO;
import locations.model.Institution;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;


public class SaveInstitutionAction extends ActionSupport implements ModelDriven<Institution>, ServletRequestAware, ServletResponseAware {
	
	private static final long serialVersionUID = -8124967730231198191L;
	
	private HttpServletRequest request; 
	private HttpServletResponse response; 
	private Institution institution = new Institution();
	
	public String execute(){
		InstitutionDAO dao = DAOFactory.getInstitutionDAO();
		dao.save(this.institution);
		return SUCCESS;
	}
	
	
	
	@Override
	public Institution getModel() {
		return this.institution;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	public Institution getInstitution() {
		return institution;
	}



	public void setInstitution(Institution institution) {
		this.institution = institution;
	}



	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}
	
	public HttpServletResponse getResponse(){
		return this.response;
	}
}
